package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.thekhaeng.slidingmenu.lib.SlidingMenu;

public class MainActivity extends AppCompatActivity {
    private Button btn;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn=findViewById(R.id.btn);

        final SlidingMenu menu = new SlidingMenu(this);
        //设置SlidingMenu，以左边弹出
        menu.setMode(SlidingMenu.LEFT);
        //设置SlidingMenu触碰屏幕的范围
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        //设置SlidingMenu，显示宽度
        menu.setBehindOffset(getWindowManager().getDefaultDisplay().getWidth() / 2);
        //设置SlidingMenu，设置渐变比率
        menu.setFadeDegree(0.35f);
        //使SlidingMenu附加在Activity上
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        //设置SlidingMenu,布局文件
        menu.setMenu(R.layout.layout_menu);
      btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              //设置单击显示，SlidingMenu
              menu.showMenu();
          }
      });

    }


}